﻿#region << 版 本 注 释 >>
/*----------------------------------------------------------------
// Copyright (C) 2021 kingerrobot
// 版权所有。 
//
// 文件名：BWmsOutOrderSummary
// 文件功能描述：
//
// 创建者：名字 (zzl)
// 时间：2021/12/21 15:56:32
//
// 修改人：
// 时间：
// 修改说明：
// 版本：V1.0.0
//----------------------------------------------------------------*/
#endregion
namespace KingerRobot.MexicoSailunWMS.SpiService;
public class BWmsOutOrderSummarySafe : IWmsOutOrderSummarySafe
{

    public POWmsOutOrderSummarySafe GetOutOrderSumarySafeByLocId(long targetLoc)
    {
        var db = Db.Default;
        var reault = db.WmsOutOrderSummarySafes.Where(t => t.TargetLoc == targetLoc && t.UseSign == "N").OrderByDescending(t => t.CreateTime).FirstOrDefault();

        return reault;
    }

    public int AddOutOrderSumarySafe(long summaryId, long targetLoc, int safe)
    {
        var db = Db.Default;
        var reault = db.WmsOutOrderSummarySafes.Insert(new POWmsOutOrderSummarySafe
        {
            Id = XID.Nextval,
            SummaryId = summaryId,
            TargetLoc = targetLoc,
            Safe = safe
        });

        return reault;
    }
    public int UpdateOutOrderSumarySafeByLocId(long targetLoc)
    {
        var db = Db.Default;
        var reault = db.WmsOutOrderSummarySafes.Where(t => t.TargetLoc == targetLoc && t.UseSign == "N").Update( new POWmsOutOrderSummarySafe
        {
            UseSign = "Y",
            UpdateTime = DateTime.Now,
        });

        return reault;
    }

}
